import { getDictDetailListApi } from '/@/api/sys/dict';
import { FormSchema } from '/@/components/Table';
import { OrgTypeEnum } from '/@/enums/sysEnum';

export const Permission = {
    ADD: 'sys.org.add',
    EDIT: 'sys.org.edit',
    DEL: 'sys.org.del',
};

export const formSchema: FormSchema[] = [
    {
        field: 'parentId',
        label: '选择上级组织机构',
        helpMessage: '不选择上级组织机构，默认是一级组织机构',
        component: 'TreeSelect',
        componentProps: {
            treeDefaultExpandAll: true,
            getPopupContainer: () => document.body,
        },
    },
    {
        field: 'pathName',
        label: '组织机构路径',
        component: 'Input',
        dynamicDisabled: true,
    },
    {
        field: 'name',
        label: '名称',
        component: 'Input',
        rules: [
            { required: true, message: '请填写名称' },
            { max: 100, message: '名称最多100字' },
        ],
    },
    {
        field: 'code',
        label: '编号',
        component: 'Input',
        helpMessage: '有下级单位的以及部门不能设置编号',
        rules: [
            { max: 100, message: '编号最多100字' },
        ],
    },
    {
        field: 'orgType',
        label: '组织机构类型',
        component: 'ApiRadioGroup',
        componentProps: {
          api: getDictDetailListApi,
          params: {
            code: 'org_type',
          },
          isBtn: true,
        },
        defaultValue: OrgTypeEnum.UNIT,
    },
    {
        field: 'orderNum',
        label: '排序编号',
        component: 'InputNumber',
        helpMessage: '值越小，显示的越靠前',
        rules: [
            { required: true, message: '请选择排序编号' },
            { type: 'number', min: 0, max: 999, message: '排序在0-999之间' },
        ],
    },
    {
        field: 'remark',
        label: '备注信息',
        component: 'InputTextArea',
        rules: [{ max: 255, message: '编号最多255字' }],
    },
];
